Date: Mon, 11 Nov 1996 17:03:27 GMT
Server: NCSA/1.5
Content-type: text/html
Last-modified: Wed, 06 Nov 1996 22:33:10 GMT
Content-length: 5234

<html>
<head><title>
CS 302 Section 10 Notes and Examples
</title></head>

<body>
<center>
<H1>CS 302 Section 10 Notes and Examples</H1>
</center>

<p>
<hr>
<p>

<H3>Chapter 1-2</H3>
Some sample programs which demonstrate material from Ch. 1.3-2.5:
<UL>
<B>C++ Basics:</B>  (Ch 1.3-2.3,2.5)
<LI><!WA0><!WA0><!WA0><A HREF="http://www.cs.wisc.edu/~msteele/cs302/notes2/ex1.cc">Baseball</A>  (Demonstrates basic
C++ structure, declaring and using variables, <tt>int</tt> vs. <tt>double</tt>,
<tt>char</tt>, <tt>cin</tt> and <tt>cout</tt>, arithmetic operators,
how to get a <tt>double</tt> result when dividing two <tt>int</tt>s, 
commenting)
<LI><!WA1><!WA1><!WA1><A HREF="http://www.cs.wisc.edu/~msteele/cs302/notes2/ex2.cc">Dividing Money</A>  (New concepts:
difference between dividing <tt>int</tt>s and <tt>double</tt>s, use of
/ and % (divide and modulus) for integers)  <I>This is similar but not
identical to the program we went over in class.</I>
<p>
<B>Flow Control:</B> (Ch 2.4)
<LI><!WA2><!WA2><!WA2><A HREF="http://www.cs.wisc.edu/~msteele/cs302/notes2/ex3.cc">Income Taxes</A>  (New concepts:
<tt>if</tt> and <tt>if-else</tt> statements, nested <tt>if</tt>
statements, use of <tt>const</tt> for constants)  <I>This is similar
but not identical to the program we went over in class.</I>
<LI><!WA3><!WA3><!WA3><A HREF="http://www.cs.wisc.edu/~msteele/cs302/notes2/ex4.cc">Multiplication Tables</A>  (New
concepts:  <tt>while</tt> and <tt>do-while</tt> loops)
</UL>

<p>

<H3>Chapter 3</H3>
Some sample programs that demonstrate material from Ch. 3:
<UL>
<LI><!WA4><!WA4><!WA4><A HREF="http://www.cs.wisc.edu/~msteele/cs302/notes3/ex1.cc">Force Equation</A>  (New concepts:
functions, prototypes vs. definitions, formal vs. actual parameters)
<I>This is similar but not identical to the program we went over in 
class.</I>
<LI><!WA5><!WA5><!WA5><A HREF="http://www.cs.wisc.edu/~msteele/cs302/notes3/ex2.cc">A Confusing Example</A>  (New concepts:
names of formal and actual parameters do not need to match, using local
variables in functions)
<LI><!WA6><!WA6><!WA6><A HREF="http://www.cs.wisc.edu/~msteele/cs302/notes3/ex3.cc">Area of Shapes</A>  (New concepts: 
function name overloading)  <I>This is the program we went over in
class.</I>
</UL>


<p>

<H3>Chapter 4</H3>
Some sample programs that demonstrate material from Ch. 4:
<UL>
<LI><!WA7><!WA7><!WA7><A HREF="http://www.cs.wisc.edu/~msteele/cs302/notes4/ex1.cc">Compass Headings</A>  (New concepts:
void functions, precondition/postcondition, re-prompting user for valid
input, a userful thing to use the % operator for)
<LI><!WA8><!WA8><!WA8><A HREF="http://www.cs.wisc.edu/~msteele/cs302/notes4/ex2.cc">Making Change</A>  (New concepts: 
call-by-reference, good use of global constants)  <I>This program is
similar but not identical to the program we wrote together in class.</I>
<LI><!WA9><!WA9><!WA9><A HREF="http://www.cs.wisc.edu/~msteele/cs302/notes4/ex3.cc">The Really Evil Simpsons Program</A>
(Concepts:  pass-by-reference vs. pass-by-value, functions calling other
functions, scope of local variables and pass-by-value variables, why
not to use global variables)  <I>This is the example we did in class.</I>
</UL>

<p>

<H3>Chapter 5</H3>
Some sample programs that demonstrate material from Ch. 5:
<UL>
<LI><!WA10><!WA10><!WA10><A HREF="http://www.cs.wisc.edu/~msteele/cs302/notes5/ex1.cc">Making a Grid of Numbers</A> (New concepts:
opening files, checking that files were opened sucessfully, closing files,
formatting output)
<LI><!WA11><!WA11><!WA11><A HREF="http://www.cs.wisc.edu/~msteele/cs302/notes5/ex2.cc">Copying Files</A> (New concepts: using <tt>get</tt>
and <tt>put</tt> for character I/O, using the <tt>eof</tt> function)
</UL>

<p>

<H3>Chapter 7</H3>
Some sample programs that demonstrate material from Ch. 7:
<UL>
<LI><!WA12><!WA12><!WA12><A HREF="http://www.cs.wisc.edu/~msteele/cs302/notes7/ex1.cc">Voting</A>  (New concepts:  <tt>switch</tt>
statements, width output manipulator inside of an output stream)  <I>This
is a fleshed out version of an example I went through in class.</I>
<LI><!WA13><!WA13><!WA13><A HREF="http://www.cs.wisc.edu/~msteele/cs302/notes7/ex2.cc">Rock, Paper, Scissors</A>  (New concepts:
<tt>enum</tt> for enumerated types, <tt>for</tt> loops, nested
<tt>switch</tt> statements)
</UL>

<p>

<H3>Chapter 6</H3>
Some sample programs that demonstrate material from Ch. 6:
<UL>
<B>These two programs do the exact same thing.</B><br>  The first example uses
a <tt>struct</tt>, the second example uses a <tt>class</tt>.
<LI><!WA14><!WA14><!WA14><A HREF="http://www.cs.wisc.edu/~msteele/cs302/notes6/ex1.cc">Increment the Date with a Struct</A>  (New
concepts:  declaring & initializing <tt>struct</tt>s, passing <tt>
struct</tt>s as arguments to functions and using them as return types
from functions, using an <tt>enum</tt> type like an integer)  <I>This
is a fleshed out version of an example I went through in class</I>
<LI><!WA15><!WA15><!WA15><A HREF="http://www.cs.wisc.edu/~msteele/cs302/notes6/ex2.cc">Increment the Date with a Class</A>
(New concepts:  declaring a class,
writing member functions for a class, initializing a class with a
constructor)  <I>This is a fleshed out version of an example I went 
through in class</I>
<p>
<LI><!WA16><!WA16><!WA16><A HREF="http://www.cs.wisc.edu/~msteele/cs302/notes6/ex3.cc">The Electric Company</A>  (New concepts:
overloading constructor functions, Abstract Data Types)  <I>This is a
fleshed out version of an example I went through in class</I>
</UL>

<p>

<H3>Chapter 9</H3>
Some sample programs that demonstrate material from Ch. 6:
<UL>
<LI><!WA17><!WA17><!WA17><A HREF="http://www.cs.wisc.edu/~msteele/cs302/notes9/ex1.cc">Points Per Game</A>  (New concepts:
declaring, initializing, and using an array, using a partially
filled array, passing an entire array as an argument to a function)
<LI>Coming soon... the <I>Library Class</I> example...
</UL>
Make sure you also understand the searching and sorting 
examples in the text book.

<p>
<hr>
<!WA18><!WA18><!WA18><A HREF="http://www.cs.wisc.edu/~msteele/cs302.html">
<!WA19><!WA19><!WA19><IMG SRC="http://www.cs.wisc.edu/~msteele/images/hand.gif" alt="<--" ALIGN=MIDDLE> Click here to
return to the CS 302 section 10 homepage</A>
<p>Last modified: Wed Nov 6, 1996 by <!WA20><!WA20><!WA20><A HREF="http://www.cs.wisc.edu/~msteele/">Mike Steele</A>
</body>
</html>

